global.jQuery = require("jquery")
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
var modernizr = require('gulp-modernizr');
var sourcemap = require('gulp-sourcemaps');




// This is php connection

var gulp = require('gulp'),
    connect = require('gulp-connect-php'),
    browserSync = require('browser-sync');

gulp.task('serve', ['sass'], function() {
    connect.server({}, function() {
        browserSync.init({
            proxy: '127.0.0.1:8000/cn/index.php'
        });
    });

    gulp.watch("./scss/*.scss", ['sass']);

    gulp.watch('./en/**/*.php').on('change', function() {
        browserSync.reload();
    });
});





gulp.task('compress', function() {
    return gulp.src('js/*.js')
        .pipe(uglify())
        .pipe(gulp.dest('js'));
});




gulp.task('modernizr', function() {
    gulp.src('./js/*.js')
        .pipe(modernizr())
        .pipe(gulp.dest("build/"))
});

// Compile sass into CSS & auto-inject into browsers
gulp.task('sass', function() {
    return gulp.src("scss/*.scss")
        .pipe(sourcemap.init())
        .pipe(sass())
        .pipe(sourcemap.write())
        .pipe(gulp.dest("css"))
        .pipe(browserSync.stream());
});

gulp.task('default', ['serve']);